package com.lordjoe.collectiveintelligence.data;

/**
 * com.lordjoe.collectiveintelligence.data.NormalizedWeightDistribution
 *
 * @author Steve Lewis
 * @date May 12, 2009
 */
public class NormalizedWeightDistribution<T extends Comparable>  implements IDistanceMetric<T>
{
    public static NormalizedWeightDistribution[] EMPTY_ARRAY = {};
    public static Class THIS_CLASS = NormalizedWeightDistribution.class;

    private MeasurementSetDistribution<T> m_Distribution;

    public NormalizedWeightDistribution(MeasurementSetDistribution<T> pDistribution)
    {
        m_Distribution = pDistribution;
    }

    public MeasurementSetDistribution<T> getDistribution()
    {
        return m_Distribution;
    }

    public double getDistance(T t1, T t2)
    {
        MeasurementSetDistribution<T> meas = getDistribution();
        double d1 = meas.normalize(t1);
        double d2 = meas.normalize(t2);
        double del = d1 - d2;
        return del * del;
    }
}


